import _ from 'lodash'

var MyState = {
    city: '汉中',
    searchlist: [],
}

export function reducer(state = MyState, action) {
    var newstate = _.cloneDeep(state);

    if (action.type == "EDIT_CITY") {
        newstate.city = action.payload
        // console.log(newstate.city);
        return newstate
    } else if (action.type == "ADD_SEARCH") {
        newstate.searchlist.push(action.payload)
        // console.log( newstate.searchlist);
        return newstate
    } else if(action.type=="QK_SEARCH"){
        newstate.searchlist=[]
        // console.log(newstate.searchlist);
        return newstate
    }else {
        return state
    }
    
}